import $ from '../dfish.js'
import '../assets/dfish.css'

import DocView from './DocView.vue'
import View from './View.vue'
import Pop from './Pop.vue'
import Dialog from './Dialog.vue'
import DialogMove from './DialogMove.vue'
import Alert from './Alert.vue'
import Confirm from './Confirm.vue'
import Tip from './Tip.vue'
import Menu from './Menu.vue'
import Loading from './Loading.vue'

import Vertical from './Vertical.vue'
import Horizontal from './Horizontal.vue'
import Table from './Table.vue'
import TableColumns from './TableColumns.vue'
import TableColumn from './TableColumn.vue'
import TableTBody from './TableTBody.vue'
import TableTHead from './TableTHead.vue'
import TableTR from './TableTR.vue'
import TableTD from './TableTD.vue'
import TableTH from './TableTH.vue'
import Grid from './Grid.vue'
import Swiper from './Swiper.vue'
import SwiperItem from './SwiperItem.vue'
import Tabs from './Tabs.vue'
import Tab from './Tab.vue'

import Album from './Album.vue'
import Img from './Img.vue'
import ButtonBar from './ButtonBar.vue'
import Button from './Button.vue'
import SubmitButton from './SubmitButton.vue'
import MenuButton from './MenuButton.vue'
import Html from './Html.vue'
import Tree from './Tree.vue'
import Leaf from './Leaf.vue'
import PageBar from './PageBar.vue'
import Split from './Split.vue'
import Toggle from './Toggle.vue'
import Video from './Video.vue'
import Progress from './Progress.vue'
import Calendar from './Calendar.vue'
import Timeline from './Timeline.vue'
import TimelineItem from './TimelineItem.vue'
import SlidePicker from './SlidePicker.vue'

import Label from './Label.vue'
import Hidden from './Hidden.vue'
import Text from './Text.vue'
import Textarea from './Textarea.vue'
import CheckBoxGroup from './CheckBoxGroup.vue'
import CheckBox from './CheckBox.vue'
import RadioGroup from './RadioGroup.vue'
import Radio from './Radio.vue'
import TripleBox from './TripleBox.vue'
import Switch from './Switch.vue'
import FileUpload from './FileUpload.vue'
import MediaUpload from './MediaUpload.vue'
import ImageUpload from './ImageUpload.vue'
import Option from './Option.vue'
import Spinner from './Spinner.vue'
import DatePicker from './DatePicker.vue'
import DropBox from './DropBox.vue'
import PickBox from './PickBox.vue'
import Password from './Password.vue'
import Range from './Range.vue'
import ComboBox from './ComboBox.vue'
import LinkBox from './LinkBox.vue'
import Jigsaw from './Jigsaw.vue'
import Form from './Form.vue'


const components = [
  DocView, View, Pop, Dialog, DialogMove, Alert, Confirm, Tip, Menu, Loading,
  Grid, Vertical, Horizontal, Table, TableColumns, TableColumn, TableTBody, TableTHead, TableTR, TableTD, TableTH, Swiper, SwiperItem, Tabs, Tab,
  Album, Img, ButtonBar, Button, SubmitButton, MenuButton, Html, Tree, Leaf, PageBar, Split, Toggle, Video, Progress, Calendar, Timeline, TimelineItem, SlidePicker,
  Label, Hidden, Text, Textarea, CheckBoxGroup, CheckBox, RadioGroup, Radio, TripleBox, Switch, FileUpload, MediaUpload, ImageUpload, Option,
  Spinner, DatePicker, DropBox, PickBox, Password, Range, ComboBox, LinkBox, Jigsaw, Form,

]

const directives = ['colspan', 'rowspan']

$.install = (Vue) => {
  //注册组件
  components.forEach(c => Vue.component(c.name, c))
  // //注册指令
  directives.forEach(v => {
    Vue.directive(v, {
      created(el, binding, vnode) {
        if ($.directiveHooks[v]) {
          if (!vnode.key) { // v-for循环内，如果vnode没有key，节点不会重新渲染，导致指令也不更新
            vnode.key = (vnode.props && vnode.props['w-key']) || $.uid()
          }         
          $.directiveHooks[v](el, binding.value, vnode)
        }
      }
    })
  })
}

export default $
